package com.usian.admin.controller;

import com.usian.apis.service.AdchannelService;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.nio.channels.Channel;
import java.util.List;

@RestController
@RequestMapping("/admin/api/channel")
@Api(value = "频道管理",tags = "channel",description ="频道管理api" )
public class AdchannelController implements AdchannelService {

    @Resource
    private com.usian.admin.service.AdchannelService adchannelService;

    /*
    * 根据姓名分页查询
    * */
    @RequestMapping("list")
    @Override
    @ApiOperation(value = "频道查询",notes = "分页查询")
    @ApiImplicitParam(name = "channelDto",type = "分页参数",value = "分页参数")
    public ResponseResult findBynameandpage(@RequestBody ChannelDto channelDto) {
        return adchannelService.findBynameandpage(channelDto);
    }

    @RequestMapping("findAll")
    public ResponseResult findAll() {
        return adchannelService.findAll();
    }


    /**
     * 判断添加
     * @param adChannel
     * @return
     */
    @PostMapping("add")
    @Override
    @ApiOperation(value = "频道添加",notes = "添加")
    public ResponseResult add(@RequestBody AdChannel adChannel) {
        return adchannelService.add(adChannel);
    }

    /**
     * 频道修改
     * @param adChannel
     * @return
     */
    @PostMapping("edit")
    @Override
    @ApiOperation(value = "频道修改",notes = "修改")
    public ResponseResult edit(@RequestBody AdChannel adChannel) {
        return adchannelService.edit(adChannel);
    }

    /**
     * 删除频道方法
     * @param id
     * @return
     */
    @GetMapping("del/{id}")
    @Override
    @ApiOperation(value = "频道删除",notes = "删除")
    public ResponseResult del(@PathVariable("id") Integer id) {
        return adchannelService.del(id);
    }
}
